package logic

import (
	"context"
	"fmt"
	"store/models/mysql"

	"store/storerpc/internal/svc"
	"store/storerpc/storerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type StoreDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewStoreDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StoreDelLogic {
	return &StoreDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *StoreDelLogic) StoreDel(in *storerpc.StoreDelRequest) (*storerpc.StoreDelResponse, error) {
	// todo: add your logic here and delete this line
	store := mysql.Store{}
	err := mysql.Db.Debug().Where("id = ?", in.Id).Delete(&store).Error
	if err != nil {
		fmt.Errorf("删除用户错误")
	}
	return &storerpc.StoreDelResponse{Id: int64(store.ID)}, nil
}
